package com.example.bbs.domain.model;


import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * web接口统一返回对象
 * @param <T> 数据
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ResponseResult<T> {

    private int code = 0;
    private String msg = "";
    private T data;


    public static <T> ResponseResult success(T data) {
        return new ResponseResult(0, "success", data);
    }

    public static ResponseResult success(String msg) {
        return new ResponseResult(0, msg, "");
    }

    public static ResponseResult success() {
        return new ResponseResult(0, "success", "");
    }



    public static ResponseResult failure(String msg) {
        return new ResponseResult(1, msg, "");
    }







}
